import { BaseDomain } from '@/common/domain/BaseDomain';
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import {
  IsNotEmpty,
  IsNumber,
  IsString,
  IsOptional,
  Matches,
} from 'class-validator';
import { queryDomain } from '@/common/domain/queryDomain';
/**@description 查询房源表Dto */
export class QueryRentalHouseDto extends queryDomain {
  @ApiProperty({ description: '房源标题', required: false })
  @IsOptional()
  title: string | null;
  @ApiProperty({ description: '房东ID', required: false })
  @IsOptional()
  @Transform((v) => +v.value)
  @IsNumber()
  ownerId: number | null;
  @ApiProperty({ description: '租金', required: false })
  @IsOptional()
  @Transform((v) => +v.value)
  @IsNumber()
  price: number | null;
  @ApiProperty({ description: '押金', required: false })
  @IsOptional()
  @Transform((v) => +v.value)
  @IsNumber()
  deposit: number | null;
  @ApiProperty({ description: '出售状态（0-已租，1-空置）', required: false })
  @IsOptional()
  status: string | null;
  @ApiProperty({ description: '房源标记（0-已删除，1-正常）', required: false })
  @IsOptional()
  delFlag: string | null;
}
/**@description 创建房源表Dto */
export class CreateRentalHouseDto {
  @ApiProperty({ description: '房源标题', required: true })
  @IsNotEmpty({ message: '房源标题不能为空' })
  @IsString()
  title: string;
  @ApiProperty({ description: '租金', required: true })
  @IsNotEmpty({ message: '租金不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  price: number;
  @ApiProperty({ description: '押金', required: true })
  @IsNotEmpty({ message: '押金不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  deposit: number;
  @ApiProperty({ description: '出售状态（0-已租，1-空置）', required: true })
  @IsNotEmpty({ message: '出售状态（0-已租，1-空置）不能为空' })
  @IsString()
  status: string;
  @ApiProperty({ description: '房源标记（0-已删除，1-正常）', required: true })
  @IsNotEmpty({ message: '房源标记（0-已删除，1-正常）不能为空' })
  @IsString()
  delFlag: string;
  @ApiProperty({ description: '房源图片', required: true })
  @IsNotEmpty({ message: '房源图片不能为空' })
  @IsString()
  image: string;
  @ApiProperty({ description: '更新时间', required: false })
  @IsOptional()
  @IsString()
  updateTime?: string;
  @ApiProperty({ description: '创建时间', required: false })
  @IsOptional()
  @IsString()
  createTime?: string;
  @ApiProperty({ description: '房源地址', required: false })
  @IsOptional()
  @IsString()
  address?: string;
  @ApiProperty({ description: '房源描述', required: false })
  @IsOptional()
  @IsString()
  description?: string;
}
/**@description 更新房源表Dto */
export class UpdateRentalHouseDto {
  @ApiProperty({ description: '房源ID' })
  @IsNotEmpty({ message: '房源ID不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  id: number;
  @ApiProperty({ description: '房源标题', required: true })
  @IsNotEmpty({ message: '房源标题不能为空' })
  @IsString()
  title: string;
  @ApiProperty({ description: '租金', required: true })
  @IsNotEmpty({ message: '租金不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  price: number;
  @ApiProperty({ description: '押金', required: true })
  @IsNotEmpty({ message: '押金不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  deposit: number;
  @ApiProperty({ description: '房源图片', required: true })
  @IsNotEmpty({ message: '房源图片不能为空' })
  @IsString()
  image: string;
  @ApiProperty({ description: '出售状态（0-已租，1-空置）', required: true })
  @IsNotEmpty({ message: '出售状态（0-已租，1-空置）不能为空' })
  @IsString()
  status: string;
  @ApiProperty({ description: '房源标记（0-已删除，1-正常）', required: true })
  @IsNotEmpty({ message: '房源标记（0-已删除，1-正常）不能为空' })
  @IsString()
  delFlag: string;
  @ApiProperty({ description: '房源地址', required: false })
  @IsOptional()
  @IsString()
  address?: string;
  @ApiProperty({ description: '房源描述', required: false })
  @IsOptional()
  @IsString()
  description?: string;
}
/**订单提交*/
export class createOrderDto {
  @ApiProperty({ description: '起始时间' })
  @IsOptional({ message: '开始时间不能为空' })
  @IsString()
  startDate: string

  @ApiProperty({ description: '结束时间' })
  @IsOptional({ message: '结束时间不能为空' })
  @IsString()
  endDate: string

  @ApiProperty({ description: '房源id' })
  @IsOptional({ message: '房源不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  houseId: number;

  @ApiProperty({ description: '房东id' })
  @IsOptional({ message: '房东id不能为空' })
  @Transform((v) => +v.value)
  @IsNumber()
  landlord: number;
}
